package com.szxy.casdemo;

import org.junit.jupiter.api.Test;

import java.util.concurrent.atomic.AtomicReference;

/**
 * @Author: zwz
 * @Date:2020/10/23 16:08
 * @Description:
 **/
public class AtomicReferenceDemo {

    public static void main(String[] args) {
        User user1 = new User("Zww", 24);
        User libai = new User("libai", 66);
        AtomicReference<Object> atomicReference = new AtomicReference<>();
        atomicReference.set(user1);
        System.out.println(atomicReference.compareAndSet(user1, libai));
        System.out.println(atomicReference.get());
    }


}
